home *** CD-ROM | disk | FTP | other *** search
/ Freelog 125 / Freelog_MarsAvril2015_No125.iso / ViePratique / ArchiFacile / ArchiFacileSetup.exe / {app} / nw.pak / Unnamed File 001159.txt < prev    next >
Text File  |  2014-10-14  |  4KB  |  108 lines

  1. // Copyright (c) 2012 Intel Corp
  2. // Copyright (c) 2012 The Chromium Authors
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. //  in the Software without restriction, including without limitation the rights
  7. //  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell co
  8. // pies of the Software, and to permit persons to whom the Software is furnished
  9. //  to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in al
  12. // l copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IM
  15. // PLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNES
  16. // S FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
  17. //  OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WH
  18. // ETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. //  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20.  
  21. var nwDispatcher = nwDispatcher || {};
  22.  
  23. (function() {
  24.   native function RequireNwGui();
  25.   native function GetAbsolutePath();
  26.  
  27.   native function GetShellIdForCurrentContext();
  28.   native function GetRoutingIDForCurrentContext();
  29.   native function CreateShell();
  30.  
  31.   native function AllocateId();
  32.   native function AllocateObject();
  33.   native function DeallocateObject();
  34.   native function CallObjectMethod();
  35.   native function CallObjectMethodSync();
  36.   native function CallStaticMethod();
  37.   native function CallStaticMethodSync();
  38.   native function CrashRenderer();
  39.   native function SetCrashDumpDir();
  40.  
  41.   native function GetNSStringWithFixup();
  42.   native function GetNSStringFWithFixup();
  43.  
  44.   nwDispatcher.requireNwGui = RequireNwGui;
  45.  
  46.   // Request a new object from browser
  47.   nwDispatcher.allocateObject = function(object, option) {
  48.     var v8_util = process.binding('v8_util');
  49.  
  50.     var id = AllocateId();
  51.     AllocateObject(id, v8_util.getConstructorName(object), option);
  52.  
  53.     // Store object id and make it readonly
  54.     Object.defineProperty(object, 'id', {
  55.       value: id,
  56.       writable: false
  57.     });
  58.  
  59.     // Deallcoate on destroy
  60.     v8_util.setDestructor(object, nwDispatcher.deallocateObject);
  61.  
  62.     // Store id to object relations, there is no delete in deallocateObject
  63.     // since this is a weak map.
  64.     global.__nwObjectsRegistry.set(id, object);
  65.   }
  66.  
  67.   // Free a object in browser
  68.   nwDispatcher.deallocateObject = function(object) {
  69.     DeallocateObject(object.id);
  70.   };
  71.  
  72.   // Call method of a object in browser.
  73.   nwDispatcher.callObjectMethod = function(object, method, args) {
  74.     CallObjectMethod(object.id,
  75.                      process.binding('v8_util').getConstructorName(object),
  76.                      method,
  77.                      args);
  78.   };
  79.  
  80.   // Call sync method of a object in browser and return results.
  81.   nwDispatcher.callObjectMethodSync = function(object, method, args) {
  82.     return CallObjectMethodSync(
  83.         object.id,
  84.         process.binding('v8_util').getConstructorName(object),
  85.         method,
  86.         args);
  87.   };
  88.  
  89.   // Call a static method.
  90.   nwDispatcher.callStaticMethod = CallStaticMethod;
  91.  
  92.   // Call a sync method of static class in browse and return.
  93.   nwDispatcher.callStaticMethodSync = CallStaticMethodSync;
  94.  
  95.   nwDispatcher.getAbsolutePath = GetAbsolutePath;
  96.   nwDispatcher.getShellIdForCurrentContext = GetShellIdForCurrentContext;
  97.   nwDispatcher.getRoutingIDForCurrentContext = GetRoutingIDForCurrentContext;
  98.   nwDispatcher.createShell = CreateShell;
  99.  
  100.   nwDispatcher.crashRenderer = CrashRenderer;
  101.   nwDispatcher.setCrashDumpDir = SetCrashDumpDir;
  102.   nwDispatcher.allocateId = AllocateId;
  103.  
  104.   nwDispatcher.getNSStringWithFixup = GetNSStringWithFixup;
  105.   nwDispatcher.getNSStringFWithFixup = GetNSStringFWithFixup;
  106.  
  107. })();
  108.